package com.xframe.xdal.core.util.redis.pool;

import com.xframe.xdal.config.RedisConfig;

public class RedisPoolCreate {


    public static IRedisPool init(RedisConfig redisConfig){
        IRedisPool pool = create(redisConfig.getType());
        if(pool != null) {
            pool.initPool(redisConfig);
        }
        return pool;
    }

    private static IRedisPool create(String typeName){
        String def = "com.xframe.xdal.core.util.redis.pool";
        IRedisPool pool = null;
        try{
            pool = (IRedisPool) Class.forName(typeName).newInstance();
        }catch(Exception ex) {
            try{
                pool = (IRedisPool) Class.forName(def + "." + typeName).newInstance();
            } catch (Exception exception) {
                pool = null;
            }
        }
        return pool;
    }

}
